home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / RDBYTAD.C < prev    next >
C/C++ Source or Header  |  1989-04-27  |  806b  |  40 lines

  1. /*    rdbytad.c 4.5        */
  2.  
  3. /*F****************************************************************************
  4.  
  5. FUNCTION NAME:    rdbytad
  6.  
  7. ACTION:        Reads a character from the A to D hardware.
  8.  
  9. PARAMETERS:
  10.         int i:    A to D Conversion Register Index.
  11.  
  12. RETURNS:    (void)
  13.  
  14. ******************************************************************************/
  15.  
  16. #define    ATODLINES    4    /* number of A to D Conversion Registers */
  17.  
  18. #include <hc11/io.h>
  19. #include <hc11/atod.h>
  20. #include <hc11/config.h>
  21. #include <hc11/directives.h>
  22.  
  23. SMALL
  24. unsigned rdbytad(i)
  25.  
  26.     int    i;
  27.  
  28.     {
  29.  
  30.     HC11.OPTION |= ADPU;
  31.  
  32.     HC11.ADCTL = HC11.ADCTL;    /* force conversion */
  33.  
  34.     while ((HC11.ADCTL & CCF) == 0)
  35.             ;        /* null statement */
  36.  
  37.     return ((unsigned) HC11.ADR[((unsigned short) i) & (ATODLINES-1)]);
  38.  
  39.     }    /* end of rdbytad    */
  40.